from django.contrib import admin
from MyBlog.my_admin_site import my_site
from app.admin import MyBaseAdmin
from log.models import RequestLogTable, ErrTable


# 请求记录
@admin.register(RequestLogTable, site=my_site)
class RequestLogTableAdmin(admin.ModelAdmin, MyBaseAdmin):
    list_display = ['id', 'ip', 'userAgent', 'httpRefer', 'requestTime', 'requestPath']
    list_display_links = list_display[:1]  # 默认的链接是id
    search_fields = list_display  # 搜索的字段同list_display
    list_filter = list_display[1:3]  # 过滤字段为前3个字段


# 错误日志
@admin.register(ErrTable, site=my_site)
class ErrTableAdmin(admin.ModelAdmin, MyBaseAdmin):
    list_display = ['id', 'ip', 'path', 'date', 'userAgent', 'reason']
    list_display_links = list_display[:1]  # 默认的链接是id
    search_fields = list_display  # 搜索的字段同list_display
    list_filter = list_display[1:3]  # 过滤字段为前3个字段
